<template>
  <div style="height: 100%;overflow: hidden;">
    <order-issue-detail :app="app"/>
    <order-monitor v-if="showMonitor" @close="showMonitor = false"/>
    <order-terminal :visible.sync="showTerminal"/>
  </div>
</template>

<script>
import user from '@mixins/user'
import OrderIssueDetail from '@/view/App/src/AirOrderManage/OrderIssueDetail'
import OrderTerminal from '@/view/Main/comps/OrderTerminal'
import OrderMonitor from '@/view/Main/comps/OrderMonitor'

import Keyboard from '@/constants/Keyboard'
import {addCtrlKeyEvent, removeCtrlKeyEvent} from '@/utils/events/keyboardListener'

export default {
  mixins: [user],
  components: {
    OrderMonitor,
    OrderTerminal,
    OrderIssueDetail},
  data () {
    return {
      title: '',
      showMonitor: false,
      showTerminal: false,
      app: {
        breadcrumbs: ['订单管理', '出票控制台', '订单详情'],
        extra: {
          localOrderId: this.$route.query['localOrderId']
        }
      }
    }
  },
  created () {
    this.$service.personal.getPersonalInfoSilence().then(res => {
      this.setUserInfo(res.data)
    }).catch(e => {})
    this.title = document.title
    document.title = '订单-' + this.app.extra.localOrderId
    addCtrlKeyEvent(Keyboard.M, this.onToggleMonitor)
    addCtrlKeyEvent(Keyboard.R, this.onToggleTerminal)
  },
  beforeDestroy () {
    document.title = this.title
    removeCtrlKeyEvent(Keyboard.M, this.onToggleMonitor)
    removeCtrlKeyEvent(Keyboard.R, this.onToggleTerminal)
  },
  methods: {
    onToggleMonitor () {
      this.showMonitor = !this.showMonitor
    },
    onToggleTerminal () {
      this.showTerminal = !this.showTerminal
    }
  }
}
</script>

<style></style>
